{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "8ece7019-182a-42c3-82ba-c1432655deea",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/letter-combinations-of-a-phone-number\n",
    "\n",
    "\n",
    "Runtime: 0 ms, faster than 100.00% of C++ online submissions for Letter Combinations of a Phone Number.\n",
    "Memory Usage: 6.9 MB, less than 10.98% of C++ online submissions for Letter Combinations of a Phone Number.\n",
    "\n",
    "\n",
    "```c++\n",
    "#include <bits/stdc++.h>\n",
    "\n",
    "using namespace std;\n",
    "\n",
    "class Solution\n",
    "{\n",
    "public:\n",
    "  vector<vector<string>> possible_set_list;\n",
    "  int length;\n",
    "\n",
    "  vector<string> loop(int index, vector<string> result) {\n",
    "    if ((index == 0) && (result.size() == 0)) {\n",
    "      return loop(index+1, possible_set_list[index]);\n",
    "    } else if (result.size() == length) {\n",
    "      return result;\n",
    "    }\n",
    "\n",
    "    vector<string> new_list;\n",
    "    for (auto &num1 : result) {\n",
    "      for (auto &num2 : possible_set_list[index]) {\n",
    "        new_list.push_back(num1+num2);\n",
    "      }\n",
    "    }\n",
    "\n",
    "    return loop(index+1, new_list);\n",
    "  }\n",
    "\n",
    "  vector<string> convert_string_to_letter_array(string text) {\n",
    "    vector<string> result_list;\n",
    "    for (char &c : text) {\n",
    "      string s;\n",
    "      s = c;\n",
    "      result_list.push_back(s);\n",
    "    }\n",
    "    return result_list;\n",
    "  }\n",
    "\n",
    "  vector<string> letterCombinations(string digits)\n",
    "  {\n",
    "    //5:42\n",
    "    possible_set_list.clear();\n",
    "    length = 1;\n",
    "\n",
    "    vector<string> result_list;\n",
    "\n",
    "    if (digits == \"\")\n",
    "    {\n",
    "      return result_list;\n",
    "    }\n",
    "\n",
    "    map<string, string> num_to_abc_map{\n",
    "        {\"2\", \"abc\"},\n",
    "        {\"3\", \"def\"},\n",
    "        {\"4\", \"ghi\"},\n",
    "        {\"5\", \"jkl\"},\n",
    "        {\"6\", \"mno\"},\n",
    "        {\"7\", \"pqrs\"},\n",
    "        {\"8\", \"tuv\"},\n",
    "        {\"9\", \"wxyz\"},\n",
    "    };\n",
    "\n",
    "    for (char &c : digits)\n",
    "    {\n",
    "      string s;\n",
    "      s = c;\n",
    "      string value = num_to_abc_map[s];\n",
    "      auto letters = convert_string_to_letter_array(value);\n",
    "      possible_set_list.push_back(letters);\n",
    "\n",
    "      length *= letters.size();\n",
    "    }\n",
    "\n",
    "    return loop(0, result_list);\n",
    "    //6:02\n",
    "  }\n",
    "};\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dd98998b-e6c6-4193-8ead-a642c301753e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "C++17",
   "language": "C++17",
   "name": "xcpp17"
  },
  "language_info": {
   "name": ""
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
